#include <QtCore>
#include <QtTest>

#include "../RScode/source/GF/gf.h"

class GF_Test : public QObject
{
  Q_OBJECT

private:
  GF gf;

public:
  GF_Test(): gf(11) {}

private Q_SLOTS:
  void initTestCase();
  void cleanupTestCase();
  void log();
  void log_data();
  void alog();
  void alog_data();
  void mul();
  void mul_data();
  void div();
  void div_data();
  void plus();
  void plus_data();
  void amul();
  void amul_data();
  void aplus();
  void aplus_data();
  void power();
  void power_data();
  void trunc();
  void trunc_data();
  void add();
  void add_data();
  void conv();
  void conv_data();
  void deconv();
  void deconv_data();
  void derivative();
  void derivative_data();
  void substitute();
  void substitute_data();
};

void GF_Test::initTestCase()
{

}

void GF_Test::cleanupTestCase()
{
}

void GF_Test::log()
{
  QFETCH(qlonglong, x);
  QFETCH(qlonglong, res);

  QCOMPARE( res, gf.log(x) );
}

void GF_Test::log_data()
{
  QTest::addColumn<qlonglong>("x");
  QTest::addColumn<qlonglong>("res");

  QTest::newRow(" log(0) ")  << qlonglong(0)  << qlonglong(-1);
  QTest::newRow(" log(1) ")  << qlonglong(1)  << qlonglong(0);
  QTest::newRow(" log(2) ")  << qlonglong(2)  << qlonglong(1);
  QTest::newRow(" log(3) ")  << qlonglong(3)  << qlonglong(3);
  QTest::newRow(" log(4) ")  << qlonglong(4)  << qlonglong(2);
  QTest::newRow(" log(5) ")  << qlonglong(5)  << qlonglong(6);
  QTest::newRow(" log(6) ")  << qlonglong(6)  << qlonglong(4);
  QTest::newRow(" log(7) ")  << qlonglong(7)  << qlonglong(5);
}

void GF_Test::alog()
{
  QFETCH(qlonglong, s);
  QFETCH(qlonglong, res);

  QCOMPARE( res, gf.alog(s) );
}

void GF_Test::alog_data()
{
  QTest::addColumn<qlonglong>("s");
  QTest::addColumn<qlonglong>("res");

  QString skel = " alog(%1) ";
  for (int i = 0; i < 8; ++i) {
    QTest::newRow( skel.arg(i).toAscii() ) << gf.log(i) << qlonglong(i);
  }
}

void GF_Test::mul()
{
  QFETCH(qlonglong, x);
  QFETCH(qlonglong, y);

  QCOMPARE(  x, gf.div( gf.mul(x, y), y )  );
}

void GF_Test::mul_data()
{
  QTest::addColumn<qlonglong>("x");
  QTest::addColumn<qlonglong>("y");

  QString skel = "  ( alog(%1) mul alog(%2) ) div %2  ";
  for (int i = 0; i < 8; ++i) {
    for (int j = 1; j < 8; ++j) {
      QTest::newRow( skel.arg(i).arg(j).toAscii() ) << qlonglong(i) << qlonglong(j);
    }
  }
}

void GF_Test::div()
{
  QFETCH(qlonglong, x);
  QFETCH(qlonglong, y);
  QFETCH(qlonglong, res);

  QCOMPARE( res, gf.div(x, y) );
}

void GF_Test::div_data()
{
  QTest::addColumn<qlonglong>("x");
  QTest::addColumn<qlonglong>("y");
  QTest::addColumn<qlonglong>("res");

  QTest::newRow(" alog(5) div alog(0) ")    << qlonglong(7) << qlonglong(1) << qlonglong(7);
  QTest::newRow(" alog(5) div alog(1) ")    << qlonglong(7) << qlonglong(2) << qlonglong(6);
  QTest::newRow(" alog(5) div alog(3) ")    << qlonglong(7) << qlonglong(3) << qlonglong(4);
  QTest::newRow(" alog(5) div alog(2) ")    << qlonglong(7) << qlonglong(4) << qlonglong(3);
  QTest::newRow(" alog(5) div alog(6) ")    << qlonglong(7) << qlonglong(5) << qlonglong(5);
  QTest::newRow(" alog(5) div alog(4) ")    << qlonglong(7) << qlonglong(6) << qlonglong(2);
  QTest::newRow(" alog(5) div alog(5) ")    << qlonglong(7) << qlonglong(7) << qlonglong(1);
  QTest::newRow(" alog(5) div alog(-inf) ") << qlonglong(0) << qlonglong(7) << qlonglong(0);
}

void GF_Test::plus()
{
  QFETCH(qlonglong, x);
  QFETCH(qlonglong, y);
  QFETCH(qlonglong, res);

  QCOMPARE( res, gf.plus(x, y) );
}

void GF_Test::plus_data()
{
  QTest::addColumn<qlonglong>("x");
  QTest::addColumn<qlonglong>("y");
  QTest::addColumn<qlonglong>("res");

  QString skel = " %1 plus %2 ";
  for (int i = 0; i < 8; ++i) {
    for (int j = 0; j < 8; ++j) {
      QTest::newRow( skel.arg(i).arg(j).toAscii() ) << qlonglong(i) << qlonglong(j) << qlonglong(i ^ j);
    }
  }
}

void GF_Test::amul()
{
  QFETCH(qlonglong, x);

  QCOMPARE(  qlonglong(1), gf.mul( gf.amul(x), x )  );
}

void GF_Test::amul_data()
{
  QTest::addColumn<qlonglong>("x");

  QString skel = " (amul %1) mul %1 ";
  for (int i = 1; i < 8; ++i) {
    QTest::newRow( skel.arg(i).toAscii() ) << qlonglong(i);
  }
}

void GF_Test::aplus()
{
  QFETCH(qlonglong, x);

  QCOMPARE(  qlonglong(0), gf.plus( gf.aplus(x), x )  );
}

void GF_Test::aplus_data()
{
  QTest::addColumn<qlonglong>("x");

  QString skel = " (aplus %1) plus %1 ";
  for (int i = 0; i < 8; ++i) {
    QTest::newRow( skel.arg(i).toAscii() ) << qlonglong(i);
  }
}

void GF_Test::power()
{
  QFETCH(qlonglong, x);
  QFETCH(qlonglong, p);
  QFETCH(qlonglong, res);

  QCOMPARE( res, gf.power(x, p) );
}

void GF_Test::power_data()
{
  QTest::addColumn<qlonglong>("x");
  QTest::addColumn<qlonglong>("p");
  QTest::addColumn<qlonglong>("res");

  QTest::newRow(" 0 pow 0 ")        << qlonglong(0) << qlonglong(0)  << qlonglong(1);
  QTest::newRow(" 0 pow 5 ")        << qlonglong(0) << qlonglong(5)  << qlonglong(0);
  QTest::newRow(" 0 pow 3 ")        << qlonglong(0) << qlonglong(3)  << qlonglong(0);
  QTest::newRow(" 1 pow 5 ")        << qlonglong(1) << qlonglong(5)  << qlonglong(1);
  QTest::newRow(" 1 pow 3 ")        << qlonglong(1) << qlonglong(3)  << qlonglong(1);
  QTest::newRow(" alog(1) pow 0 ")  << gf.alog(1)   << qlonglong(0)  << qlonglong(1);
  QTest::newRow(" alog(4) pow 0 ")  << gf.alog(4)   << qlonglong(0)  << qlonglong(1);
  QTest::newRow(" alog(5) pow 0 ")  << gf.alog(5)   << qlonglong(0)  << qlonglong(1);
  QTest::newRow(" alog(1) pow 4 ")  << gf.alog(1)   << qlonglong(4)  << gf.alog(4);
  QTest::newRow(" alog(4) pow 3 ")  << gf.alog(4)   << qlonglong(3)  << gf.alog(5);
  QTest::newRow(" alog(2) pow 5 ")  << gf.alog(2)   << qlonglong(5)  << gf.alog(3);
  QTest::newRow(" alog(3) pow -2 ") << gf.alog(3)   << qlonglong(-2) << gf.alog(1);
}

void GF_Test::trunc()
{
  QFETCH(void *, pPoly);
  QFETCH(void *, pRes);

  QVector<qlonglong> polyTrunc = gf.trunc(  *( (QVector<qlonglong> *)pPoly )  );
  QVector<qlonglong> res = *( (QVector<qlonglong> *)pRes );

  QVERIFY( res == polyTrunc? true: false );
}

void GF_Test::trunc_data()
{
  QTest::addColumn<void *>("pPoly");
  QTest::addColumn<void *>("pRes");

  QTest::newRow(" trunc 0 1 0 5 0 0 ")
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 0 << 1 << 0 << 5 << 0 << 0 )  )
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 0 << 1 << 0 << 5 )  );
  QTest::newRow(" trunc 0 1 0 5 0 6 ")
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 0 << 1 << 0 << 5 << 0 << 6 )  )
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 0 << 1 << 0 << 5 << 0 << 6 )  );
  QTest::newRow(" trunc 0 9 0")
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 0 << 9 << 0 )  )
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 0 << 9 )  );
  QTest::newRow(" trunc 0 0 0 0")
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 0 << 0 << 0 << 0 )  )
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 0 )  );
  QTest::newRow(" trunc 0 ")
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 0 )  )
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 0 )  );
  QTest::newRow(" trunc 5 ")
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 5 )  )
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 5 )  );
}

void GF_Test::derivative()
{
  QFETCH(void *, pPoly);
  QFETCH(void *, pRes);

  QVector<qlonglong> derivative = gf.derivative(  *( (QVector<qlonglong> *)pPoly )  );
  QVector<qlonglong> res = *( (QVector<qlonglong> *)pRes );

  QVERIFY( res == derivative? true: false );
}

void GF_Test::derivative_data()
{
  QTest::addColumn<void *>("pPoly");
  QTest::addColumn<void *>("pRes");

  QTest::newRow(" derivative alog(4) + alog(3)*x + alog(3)*x^2 ")
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << gf.alog(4) << gf.alog(3) << gf.alog(3) )  )
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << gf.alog(3) )  );
  QTest::newRow(" derivative 1 + alog(6)*x + alog(6)*x^2 ")
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 1 << gf.alog(6) << gf.alog(6) )  )
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << gf.alog(6) )  );
  QTest::newRow(" derivative 1 + alog(6)*x ")
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 1 << gf.alog(6) )  )
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << gf.alog(6) )  );
  QTest::newRow(" derivative 1 ")
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 1 )  )
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 0 )  );
  QTest::newRow(" derivative alog(6) ")
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << gf.alog(6) )  )
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 0 )  );
  QTest::newRow(" derivative alog(6)*x^2 ")
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 0 << 0 << gf.alog(6) )  )
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 0 )  );
}

void GF_Test::substitute()
{
  QFETCH(void *, pPoly);
  QFETCH(qlonglong, x);
  QFETCH(qlonglong, res);

  qlonglong val = gf.substitute(  *( (QVector<qlonglong> *)pPoly ), x  );

  QCOMPARE(res, val);
}

void GF_Test::substitute_data()
{
  QTest::addColumn<void *>("pPoly");
  QTest::addColumn<qlonglong>("x");
  QTest::addColumn<qlonglong>("res");

  QTest::newRow(" alog(6) substitute alog(2) ")
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << gf.alog(6) )  )
      << gf.alog(2)
      << gf.alog(6);
  QTest::newRow(" alog(6) substitute alog(6) ")
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << gf.alog(6) )  )
      << gf.alog(6)
      << gf.alog(6);
  QTest::newRow(" 1 + alog(3)*x substitute alog(2) ")
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 1 << gf.alog(3) )  )
      << gf.alog(2)
      << gf.alog(4);
  QTest::newRow(" 1 + alog(3)*x substitute alog(6) ")
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 1 << gf.alog(3) )  )
      << gf.alog(6)
      << gf.alog(6);
  QTest::newRow(" 1 + alog(3)*x substitute 0 ")
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 1 << gf.alog(3) )  )
      << qlonglong(0)
      << qlonglong(1);
  QTest::newRow(" alog(4) + x substitute alog(2) ")
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << gf.alog(4) << 1 )  )
      << gf.alog(2)
      << gf.alog(1);
  QTest::newRow(" alog(4) + x substitute alog(6) ")
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << gf.alog(4) << 1 )  )
      << gf.alog(6)
      << gf.alog(3);
}

void GF_Test::add()
{
  QFETCH(void *, pP1);
  QFETCH(void *, pP2);
  QFETCH(void *, pRes);

  QVector<qlonglong> p1 = *( (QVector<qlonglong> *)pP1 );
  QVector<qlonglong> p2 = *( (QVector<qlonglong> *)pP2 );
  QVector<qlonglong> res = *( (QVector<qlonglong> *)pRes );

  QVERIFY( res == gf.add(p1, p2)? true: false );
}

void GF_Test::add_data()
{
  QTest::addColumn<void *>("pP1");
  QTest::addColumn<void *>("pP2");
  QTest::addColumn<void *>("pRes");

  QTest::newRow(" x^4 add alog(5)*x + alog(6)*x^2 + x^4 ")
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 0 << 0 << 0 << 0 << 1 )  )
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 0 << 7 << 5 << 0 << 1 )  )
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 0 << 7 << 5 << 0 << 0 )  );
  QTest::newRow(" alog(4) + alog(5)*x + alog(6)*x^3 add alog(5)*x^2 + alog(6)*x^3 ")
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 6 << 7 << 0 << 5 )  )
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 0 << 0 << 7 << 5 )  )
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 6 << 7 << 7 << 0 )  );
  QTest::newRow(" alog(4) + alog(5)*x + alog(5)*x^2 add alog(4)*x + alog(5)*x^2 ")
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 6 << 7 << 7 )  )
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 0 << 6 << 7 )  )
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 6 << 1 << 0 )  );
  QTest::newRow(" alog(4) + x add alog(4) + alog(5)*x + alog(5)*x^2 ")
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 6 << 1 )  )
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 0 << 6 << 7 )  )
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 6 << 7 << 7 )  );
  QTest::newRow(" alog(4) + x add alog(4) + x ")
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 6 << 1 )  )
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 6 << 1 )  )
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 0 << 0 )  );
}

void GF_Test::conv()
{
  QFETCH(void *, pP1);
  QFETCH(void *, pP2);
  QFETCH(void *, pRes);

  QVector<qlonglong> p1 = *( (QVector<qlonglong> *)pP1 );
  QVector<qlonglong> p2 = *( (QVector<qlonglong> *)pP2 );
  QVector<qlonglong> res = *( (QVector<qlonglong> *)pRes );

  QVERIFY( res == gf.conv(p1, p2)? true: false );
}

void GF_Test::conv_data()
{
  QTest::addColumn<void *>("pP1");
  QTest::addColumn<void *>("pP2");
  QTest::addColumn<void *>("pRes");

  QTest::newRow(" 1 + alog(4)*x + alog(4)*x^2 conv 1 + alog(6)*x + alog(6)*x^2 ")
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 1 << gf.alog(4) << gf.alog(4) )  )
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 1 << gf.alog(6) << gf.alog(6) )  )
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 1 << gf.alog(3) << 0 << 0 << gf.alog(3) )  );
  QTest::newRow(" alog(4) + alog(5)*x + alog(6)*x^3 conv 1 + x + alog(1)*x^2 ")
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << gf.alog(4) << gf.alog(5) << 0 << gf.alog(6) )  )
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 1 << 1 << gf.alog(1) )  )
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << gf.alog(4) << 1 << 0 << 0 << gf.alog(6) << 1 )  );
  QTest::newRow(" 3 + 3*x^2 conv alog(6) + alog(5)*x + alog(5)*x^2 + alog(2)*x^3 + x^4 ")
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 3 << 0 << 3 )  )
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << gf.alog(6) << gf.alog(5)
                                                                 << gf.alog(5) << gf.alog(2) << 1 )  )
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 4 << 2 << 6 << 5 << 1 << 7 << 3 )  );
}

void GF_Test::deconv()
{
  QFETCH(void *, pP1);
  QFETCH(void *, pP2);
  QFETCH(void *, pDiv);
  QFETCH(void *, pMod);

  QVector<qlonglong> p1 = *( (QVector<qlonglong> *)pP1 );
  QVector<qlonglong> p2 = *( (QVector<qlonglong> *)pP2 );
  QVector<qlonglong> div = *( (QVector<qlonglong> *)pDiv );
  QVector<qlonglong> mod = *( (QVector<qlonglong> *)pMod );

  QVERIFY( div == gf.deconv(p1, p2).div? true: false );
  QVERIFY( mod == gf.deconv(p1, p2).mod? true: false );
}

void GF_Test::deconv_data()
{
  QTest::addColumn<void *>("pP1");
  QTest::addColumn<void *>("pP2");
  QTest::addColumn<void *>("pDiv");
  QTest::addColumn<void *>("pMod");

//  QTest::newRow(" 1 + alog(3)*x + alog(3)*x^4 deconv x^4 ")
//      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 1 << gf.alog(3) << 0 << 0 << gf.alog(3) )  )
//      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 0 << 0 << 0 << 0 << 1 )  )
//      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << gf.alog(3) )  )
//      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 1 << gf.alog(3) )  );
//  QTest::newRow(" x^4 deconv 1 + alog(4)*x + alog(4)*x^2 ")
//      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 0 << 0 << 0 << 0 << 1 )  )
//      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 1 << gf.alog(4) << gf.alog(4) )  )
//      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << gf.alog(4) << gf.alog(3) << gf.alog(3) )  )
//      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << gf.alog(4) << 1 )  );
//  QTest::newRow(" x^4 deconv alog(4) + alog(5)*x + alog(6)*x^3 ")
//      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 0 << 0 << 0 << 0 << 1 )  )
//      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << gf.alog(4) << gf.alog(5) << 0 << gf.alog(6) )  )
//      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 0 << gf.alog(1) )  )
//      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 0 << gf.alog(5) << gf.alog(6) )  );
//  QTest::newRow(" alog(4) + alog(5)*x + alog(6)*x^3 deconv alog(5)*x + alog(6)*x^2 ")
//      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << gf.alog(4) << gf.alog(5) << 0 << gf.alog(6) )  )
//      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 0 << gf.alog(5) << gf.alog(6) )  )
//      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << gf.alog(6) << 1 )  )
//      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << gf.alog(4) << 1 )  );
//  QTest::newRow(" 1 + alog(3)*x + alog(3)*x^4 deconv 1 + alog(6)*x + alog(6)*x^2 ")
//      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 1 << gf.alog(3) << 0 << 0 << gf.alog(3) )  )
//      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 1 << gf.alog(6) << gf.alog(6) )  )
//      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 1 << gf.alog(4) << gf.alog(4) )  )
//      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 0 )  );
//  QTest::newRow(" alog(4) + x + alog(6)*x^4 + x^5 deconv alog(4) + alog(5)*x + alog(6)*x^3 ")
//      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << gf.alog(4) << 1 << 0 << 0 << gf.alog(6) << 1 )  )
//      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << gf.alog(4) << gf.alog(5) << 0 << gf.alog(6) )  )
//      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 1 << 1 << gf.alog(1) )  )
//      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 0 )  );
//  QTest::newRow(" 4 + 2*x + 6*x^2 + 5*x^3 + x^4 + 7*x^5 + 3*x^6 deconv"
//                " alog(6) + alog(5)*x + alog(5)*x^2 + alog(2)*x^3 + x^4 ")
//      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 4 << 2 << 6 << 5 << 1 << 7 << 3 )  )
//      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << gf.alog(6) << gf.alog(5)
//                                                                 << gf.alog(5) << gf.alog(2) << 1 )  )
//      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 3 << 0 << 3 )  )
//      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 0 )  );
//p1:  QVector(3, 4, 2, 1)
//p2:  QVector(6)
  QTest::newRow(" 3 + 4*x + 2*x^2 + x^3 deconv 6 ")
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 3 << 4 << 2 << 1 )  )
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 6 )  )
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << gf.alog(6) << gf.alog(5)
                                                                 << gf.alog(4) << gf.alog(3) )  )
      << (void *)(  new QVector<qlonglong>( QVector<qlonglong>() << 0 )  );
}

QTEST_APPLESS_MAIN(GF_Test);

#include "gf_test.moc"
